package org.gp.core.web;

import com.alibaba.fastjson.JSON;
import org.gp.core.entity.dto.ResponseDTO;
import org.gp.core.entity.result.BarData;
import org.gp.core.entity.result.PieData;
import org.gp.core.service.IBillService;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 账单表  前端控制器
 * </p>
 *
 * @author LuoLiang
 * @since 2017-02-27
 */
@RestController
@RequestMapping("/bill")
public class BillController {
    @Resource
    private IBillService billService;

    @RequestMapping(value = "/pieChartData", method = RequestMethod.GET)
    public String pieChartData(@CookieValue("USERID") Integer userId) {
        ResponseDTO<List<PieData>> dto = billService.getPieChartData(1);

        return JSON.toJSONString(dto);
    }

    @RequestMapping(value = "/barChartData", method = RequestMethod.GET)
    public String barChartData(Integer userId) {
        ResponseDTO<BarData> dto = billService.getBarChartData(1);

        return JSON.toJSONString(dto);
    }

    @RequestMapping(value = "/lineChartData", method = RequestMethod.GET)
    public String lineChartData(Integer userId) {
        ResponseDTO dto = billService.getLineData(1);

        return JSON.toJSONString(dto);
    }


}
